import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';

const add = (a,b) => {
  console.log('函数执行了');
  return a+b
}

function memoize(func) {
  const cache = {};
  return function(...args) {
    const key = JSON.stringify(args)
    return cache[key] || (cache[key] = func.apply(this, args))
  }
}
const cacheFunc = memoize(add)
console.log(cacheFunc(1,2));
cacheFunc(1,2)
cacheFunc(1,2)

// 求1到100的和
const getSum = (n) => {
  if(n === 1){
    return 1
  }
  return getSum(n-1) + n
}
console.log(getSum(100));


ReactDOM.render(
    <React.StrictMode>
      <App />
    </React.StrictMode>
  ,
  document.getElementById('root')
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
